#ifndef __H_MVP_TRANSPORT_PPS_H__
#define __H_MVP_TRANSPORT_PPS_H__

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <fcntl.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/poll.h>
#include <string>
#include <memory>
#include <thread>
#include <functional>

// #include "Logger/Logger.h"
#include "transport/pps/pps_api.h"

namespace motovis {
namespace transport {
namespace pps {

template <typename MessageT>
class PpsReceiver;

class PPS {
public:
    using Callback = std::function<void(const pps::ReceiveData *)>;

    PPS(const std::string &channelName, const bool &model);

    virtual ~PPS();

    bool publish(const void *data, unsigned int dataLen);

    void subscribe(Callback &cb);

private:
    int m_fd;

    std::string m_channelName;

    ReceiveData m_receiveData;

    std::shared_ptr<std::thread> m_thread;

    void exec(Callback &cb);
};

} // namespace pps
} // namespace transport
} // namespace motovis

#endif // __H_MVP_TRANSPORT_PPS_H__
